<template>
    <div class="container">
        <ul class="contral" @click.stop="chage_aaa">
            <li>
                <span @click.stop="change_bbb">图层控制</span>
                <ul class="layer-ul">
                    <li>测试1</li>
                    <li>测试2</li>
                    <li>测试3</li>
                    <li>测试4</li>
                    <li>测试5</li>
                    <li>测试6</li>
                    <li>测试1</li>
                    <li>测试2</li>
                    <li>测试3</li>
                    <li>测试4</li>
                    <li>测试5</li>
                    <li>测试6</li>
                    <li>测试1</li>
                    <li>测试2</li>
                    <li>测试3</li>
                    <li>测试4</li>
                    <li>测试5</li>
                    <li>测试6</li>
                </ul>

            </li>
            <li>
                <span>图例</span>
            </li>
        </ul>
    </div>
</template>

<script lang="ts" setup>

function chage_aaa() {
    console.log("点击测试1");
    
}
function change_bbb() {
    console.log("点击测试2");
    
}
</script>

<style lang="scss" scoped>
.container {
    position: relative;
    display: flex;
    width: 100px;
    height: 100px;
    background-color: #95a5a6;
    border-radius: 10px;
    transition: background-color .5s;

    &:hover {
        background-color: #ff7675;
    }

    &:hover .contral {
        opacity: 1;
    }
}

.contral {
    position: absolute;
    left: -100%;
    top: 100%;
    margin: 0;
    list-style: none;
    opacity: 1;
    background-color: #c7ecee;
    border-radius: 4px;
    font-size: 13px;
    transition: opacity .5s;

    & li:nth-child(1):hover {
        //position: relative;
        background-color: #70a1ff;
    }
    & li:nth-child(1):hover .layer-ul {
        opacity: 1;
    }
}

.layer-ul {
    width: 150px;
    height: 20vh;
    overflow-y: auto;
    position: absolute;
    padding: 0;
    left: -200%;
    top: -50%;
    margin-right: calc(100% + 20px);
    list-style: none;
    opacity: 1;
    background-color: #c7ecee;
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    border-radius: 4px;
    font-size: 13px;
    transition: opacity .5s;

    & li {
        width: calc(100% / 2 - 5px);
    }

    & li:hover {
        background-color: #70a1ff;
    }
}
</style>